package com.common.sdk.net.download.util;

import java.util.Comparator;

import com.common.sdk.net.download.request.model.DownloadInfo;

public class DownloadInfoComparatorUtils implements Comparator<DownloadInfo> {

    @Override
    public int compare(DownloadInfo leftDownloadInfo, DownloadInfo rightDownloadInfo) {
        if (leftDownloadInfo.getDownloadPriority() > rightDownloadInfo.getDownloadPriority()) {
            return -1;
        } else if (leftDownloadInfo.getDownloadPriority() == rightDownloadInfo.getDownloadPriority()) {
            if (leftDownloadInfo.getRequestStartTime() > rightDownloadInfo.getRequestStartTime()) {
                return 1;
            } else if (leftDownloadInfo.getRequestStartTime() == rightDownloadInfo.getRequestStartTime()) {
                return 0;
            } else {
                return -1;
            }
        } else {
            return 1;
        }
    }

}
